package com.audaque.springboot.foshanupload.reactor.webfluxdemo.controller;


import com.audaque.springboot.foshanupload.reactor.webfluxdemo.model.pojo.UserMongodb;
import com.audaque.springboot.foshanupload.reactor.webfluxdemo.service.iface.UserMongodbService;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

/**
 * 用户增删改查接口.
 *
 * @author zgb
 * @date 2021-05-08 16:09
 */
@RestController
@RequestMapping("/user")
public class UserMongodbController {

    @Resource
    UserMongodbService userMongodbService;

    @PostMapping("/add")
    public Mono<String> addUser(@RequestBody UserMongodb params) {
        return userMongodbService.addUser(params);
    }

    @DeleteMapping("/delete")
    public Mono<String> deleteUser(@Param("id") String id) {
        return userMongodbService.deleteUser(id);
    }

    @PostMapping("/edit")
    public Mono<String> editUser(@RequestBody UserMongodb params) {
        return userMongodbService.editUser(params);
    }

    @GetMapping("/query")
    public Mono<UserMongodb> queryUserById(@Param("id") String id) {
        return userMongodbService.queryUserById(id);
    }


}
